package com.imooc.miaosha.controller;

import com.imooc.miaosha.myredis.MyRedisService;
import com.imooc.miaosha.pojo.ApiResultTo;
import com.imooc.miaosha.pojo.domain.MiaoshaUser;
import com.imooc.miaosha.pojo.vo.GoodsVo;
import com.imooc.miaosha.service.GoodsService;
import com.imooc.miaosha.service.MiaoshaUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    GoodsService goodsService;

    @Autowired
    MyRedisService redisService;

    @RequestMapping(value = "/goods_list", method = RequestMethod.POST)
    public ApiResultTo<List<GoodsVo>> goodsList(){
        return ApiResultTo.buildSuccess(goodsService.listGoodsVo());
    }

    @RequestMapping(value = "/to_detail", method = RequestMethod.POST)
    public ApiResultTo<GoodsVo> goodsDetail(@RequestParam(name = "goodsId")long goodsId){
        return ApiResultTo.buildSuccess(goodsService.findGoodsVoById(goodsId));
    }
}
